/*
 * @Date: 2020-08-07 09:11:49
 * @LastEditors: xujianxing
 * @LastEditTime: 2020-08-07 14:32:50
 * @FilePath: \my-umi\src\app.tsx
 */

import React from 'react';
import About from '@/pages/about/[id]';

/**
 * 监听路由改变
 * @param param0 路由参数
 */
export function onRouteChange({ matchedRoutes }: any) {
  if (matchedRoutes.length) {
    document.title = matchedRoutes[matchedRoutes.length - 1].route.title || '';
  }
}

/**
 * 应用额外的路由
 * patchRoutes({routes})
 */
export function patchRoutes({ routes }: any) {
  routes.unshift({
    path: '/foo',
    exact: true,
    component: About,
  });
}

/**
 * 渲染根实例的容器
 * @param container 当前容器
 * @param args 参数包括：routes, plugins, history
 */
export function rootContainer(container: any, args: any) {
  return React.createElement(React.Fragment, null, container);
}
